home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-05-09 | 952 b | 38 lines | [TEXT/PICN] |
- ############################################################################
- #
- # tail.icn
- #
- # This program writes the last lines of a file to the Interactive
- # window, or to a file if Program Output has been redirected. The user
- # is prompted with a Get File dialog and the program continues to
- # process files until the user selects Cancel in a file dialog.
- #
- # Option:
- #
- # n Number of lines to write. The default is 10.
- #
- ############################################################################
-
- procedure main(args)
- local i, infile, tail, name
-
- i := integer(args[1]) | 10
- while name := getfile("File?") do {
- close(\infile)
- infile := open(name) | {
- write(&errout,"*** cannot open ",name)
- next
- }
- tail := []
- every 1 to i do {
- put(tail,read(infile)) | {
- while write(get(tail)) # short file
- exit()
- }
- }
- while put(tail,read(infile)) do
- get(tail)
- while write(get(tail))
- }
- end
-